package com.peng.leetcode.queue;

import java.util.ArrayDeque;
import java.util.LinkedList;
import java.util.Queue;

/**
 * BuildQueue
 *
 * @author: lupeng6
 * @create: 2020/12/22 11:09
 */
public class BuildQueue {


    public static void main(String[] args) {
        Queue<Integer> queue = buildLinkQueue(1, 2, 3, 4, 5, 6, 7);
        while (!queue.isEmpty()) {
            System.out.println(queue.poll());
        }
    }

    /**
     * 构建一个链表队列
     *
     * @author lupeng6
     * @date 2020/12/22 11:14
     */
    public static Queue<Integer> buildLinkQueue(int... values) {
        Queue<Integer> queue = new LinkedList<>();
        for (int value : values) {
            queue.offer(value);
        }
        return queue;
    }


    public static Queue<Integer> buildArrayQueue(int... values) {
        Queue<Integer> queue = new ArrayDeque<>();
        for (int value : values) {
            queue.offer(value);
        }
        return queue;
    }
}
